let ajaxTime = 0
export const request = (url,method,params,header) =>{
  ajaxTime++
  uni.showLoading({
    title: '正在加载中',
    mask: true
  })
  return new Promise((resolve,reject)=>{
    uni.request({
      url: 'https://api-hmugo-web.itheima.net/api/public/v1/' + url,
      method,
      data: params,
      header,
      success:(res) =>{
        resolve(res);
      },
      fail:(err)=>{
        reject(err);
      },
      complete:()=>{
        ajaxTime--
        if(ajaxTime === 0){
          uni.hideLoading()
        }
      }
    });
  })
}